<?php
declare (strict_types=1);

namespace Plugin\Organization\Model;

use App\Model\Permission\User;
use Mine\MineModel;

class RdOrganizeUserApply extends MineModel
{
    /**
     * The table associated with the model.
     *
     * @var string|null
     */
    protected ?string $table = 'rd_organize_user_apply';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected array $fillable = [
        'id', 'user_id', 'area', 'area_ids', 'apply_id', 'status', 'created_at', 'updated_at', 'remark', 'role', 'name', 'apply_data'
    ];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected array $casts = [
        'user_id' => 'integer',
        'area' => 'integer',
        'area_ids' => 'array',
        'apply_id' => 'integer',
        'status' => 'integer',
        'created_at' => 'datetime',
        'updated_at' => 'datetime',
        'role' => 'integer',
        'apply_data' => 'array'
    ];

    /**
     * 关联申请人
     */
    public function user()
    {
        return $this->belongsTo(User::class, 'user_id');
    }

    /**
     * 关联审批人
     */
    public function applyUser()
    {
        return $this->belongsTo(User::class, 'apply_id');
    }
}